/**   
* @Package com.app.open.sys.user.dao 
*/
package com.wlyy.bcwlw.sys.user.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.rework.joss.persistence.convention.BaseDao;
import com.wlyy.bcwlw.sys.user.entity.UserDTO;

/**
 * @ClassName. UserDAO
 * @Description. TODO
 * @author zhangyang
 * @date 2015年7月24日 下午4:36:35
 * @version V1.0
 */
@Repository
public class UserDAO extends BaseDao<UserDTO, String>{

	public int removeUserByUserIds(String [] userIds){
		return this.sqlSessionTemplate.delete(getMapperMethodId("removeUserByUserIds"), userIds);
	}
	
	public List<UserDTO> queryUserInfo(String areaId){
		return this.sqlSessionTemplate.selectList(getMapperMethodId("queryUserInfo"),areaId);
	}
	
	public List<UserDTO> queryUserWithNoArea(){
		return this.sqlSessionTemplate.selectList(getMapperMethodId("queryUserWithNoArea"));
	}
	
	public int setUserAreaIsNullByAreaId(String areaId){
		return this.sqlSessionTemplate.update(getMapperMethodId("setUserAreaIsNullByAreaId"),areaId);
	}
	
	public int setUserAreaIsNull(String [] userIds){
		return this.sqlSessionTemplate.update(getMapperMethodId("setUserAreaIsNull"), userIds);
	}
	
	public List<UserDTO> queryUsershasRole(String roleId){
		return this.sqlSessionTemplate.selectList(getMapperMethodId("queryUsershasRole"), roleId);
	}
	
	public List<UserDTO> queryUsersNotHasRole(String roleId){
		return this.sqlSessionTemplate.selectList(getMapperMethodId("queryUsersNotHasRole"), roleId);
	}
	
	public List<UserDTO> searchByUsernameOrName(String query){
		return this.sqlSessionTemplate.selectList(getMapperMethodId("searchByUsernameOrName"),query);
	}
	
	public UserDTO findByUserName(String userName){
		return this.sqlSessionTemplate.selectOne(getMapperMethodId("findUserByUserName"), userName);
	}
	
	public UserDTO findByUserId(String userId){
		return this.sqlSessionTemplate.selectOne(getMapperMethodId("findUserByUserId"), userId);
	}
	
	public List<UserDTO> queryUserByPermissionId(String permissionId){
		return this.sqlSessionTemplate.selectList(getMapperMethodId("queryUserByPermissionId"),permissionId);
	}
	
	public List<String> findUserOwnRolesById(String userId){
		return this.sqlSessionTemplate.selectList(getMapperMethodId("findUserOwnRolesById"), userId);
	}
	
	public List<UserDTO> queryUserByUserNameWithPassword(UserDTO userDTO){
		return this.sqlSessionTemplate.selectList(getMapperMethodId("queryUserByUserNameWithPassword"), userDTO);
	}
	
	public List<UserDTO> findUserList(String[] ids,String blockUser,String orderby){
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("array",ids);
		map.put("blockUser", blockUser);
		map.put("orderby", orderby);
		return this.sqlSessionTemplate.selectList(getMapperMethodId("findUserList"), map);
		
		
	}
	
	public UserDTO queryUserByOwnDevId(String devId){
		return this.sqlSessionTemplate.selectOne(getMapperMethodId("queryUserByOwnDevId"), devId);
	}
	
}
